package edu.pku.sei.act.ctrl.command;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.act.model.common.ArchiModel;
import edu.pku.sei.act.model.mote.TaskEditArea;;

public class CreateTaskEditAreaCommand extends Command{
	
	private ArchiModel model;
	private TaskEditArea taskEditArea;
	
	public CreateTaskEditAreaCommand(ArchiModel model, TaskEditArea taskEditArea) {
		super("Create Package");
		this.model = model;
		this.taskEditArea = taskEditArea;
	}
	
	public boolean canExecute() {
		return model != null && taskEditArea != null ;
	}
	
	public void execute() {
		if (model != null) {
			taskEditArea.setContainer(model);
			model.getRootElements().add(taskEditArea);
		}
	}
	
	public void undo() {
		if (model != null) {
			model.getRootElements().remove(taskEditArea);
		}
		taskEditArea.setContainer(null);
	}
	
	public void redo(){
		this.execute();
	}

}
